﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace Media.Core.Data
{
    public interface IDatabase
    {
        IDBRepo Linq { get; }
        void CommitChanges();
        void Dispose();
    }

    public sealed partial class Database : IDisposable, IDatabase
    {
        public IDBRepo Linq { get; private set; }
        private readonly DbConnection _connection;

        public Database()
        {
            var connectionstring = ConfigurationManager.ConnectionStrings["MovieDBContext"].ConnectionString;

            Linq = new DBRepo(connectionstring);
        }

        public void CommitChanges()
        {
            if (Linq != null)
            {
                Linq.CommitChanges();
            }
        }

        public void Dispose()
        {
            Linq.Dispose();
        }
    }
}

